//定义计分牌
class ScorePanel{
    score = 0;
    level = 1;
    scoreEle:HTMLElement;
    levelEle:HTMLElement;
    //最大等级
    maxLevel:number;
    //多少分升一级
    upScore:number;
    constructor(maxLevel:number = 16,upScore:number = 2){
        this.scoreEle = document.querySelector('#score span')!;
        this.levelEle = document.querySelector('#level span')!;
        this.maxLevel = maxLevel;
        this.upScore = upScore;
    }
    //加分函数
    addScore(){
        this.scoreEle.innerHTML = ++this.score+'';
        //分数达到整十就升一级
        if(this.score%this.upScore === 0){
            this.levelup();
        }
    }
    //升级函数
    levelup(){
        if(this.level<this.maxLevel){
            this.levelEle.innerHTML = ++this.level+'';
        }
    }
}
export default ScorePanel;